package com.sevenre.trackre.driver.datatypes;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sevenre.trackre.driver.R;

public class TripAdapter extends BaseAdapter {

	private ArrayList<Trip> data;
	LayoutInflater inflater;
	int i = 0;
	int inflate;

	public TripAdapter(Activity a, ArrayList<Trip> d, int l) {
		data = d;
		inflate = l;
		inflater = (LayoutInflater) a
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View vi = convertView;
		vi = inflater.inflate(inflate, null);

		TextView route_no = (TextView) vi.findViewById(R.id.list_item_trip_route_no);
		TextView time = (TextView) vi.findViewById(R.id.list_item_trip_time);
		TextView type = (TextView) vi.findViewById(R.id.list_item_trip_type);

		Trip t = (Trip) data.get(position);
		route_no.setText(t.getname());
		time.setText(t.getTime());
		type.setText(t.getDisplayName());

		return vi;
	}
	
	@Override
	public int getCount() {
		if (data.size() <= 0)
			return 1;
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		return (position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	
}